"""
@author: wg
@file: 读取前五行.py
@time: 2023/12/12 21:38
"""

# 使用python读取/etc/ssh/sshd_config文件，读取它的前5行
#    过滤掉以#号开头的行和空行输出

with open('/etc/ssh/sshd_config', 'r') as f:
    # 读取前5行
    for i in range(5):
        line = f.readline()
        # 过滤掉以#号开头的行和空行
        if not line.startswith('#') and line.strip():
            print(line.strip())
